package com.suemi.missile.common.mql;

import com.suemi.missile.common.mql.exception.MqlFeatureNotSupportedException;
import com.suemi.missile.common.mql.exception.MqlParseException;
import com.suemi.missile.common.mql.query.ESActionFactory;
import com.suemi.missile.common.mql.query.QueryAction;
import org.elasticsearch.client.Client;

import java.util.HashSet;
import java.util.Set;

public class SearchDao {

  private static final Set<String> END_TABLE_MAP = new HashSet<>();

  static {
    END_TABLE_MAP.add("limit");
    END_TABLE_MAP.add("order");
    END_TABLE_MAP.add("where");
  }

  private Client client = null;


  public SearchDao(Client client) {
    this.client = client;
  }

  public Client getClient() {
    return client;
  }

  /**
   * Prepare action And transform sql
   * into ES ActionRequest
   * @param mql MQL query to execute.
   * @return ES request
   * @throws MqlParseException,MqlFeatureNotSupportedException
   */
  public QueryAction explain(String mql) throws MqlParseException, MqlFeatureNotSupportedException {
    return ESActionFactory.create(client,mql);
  }



}

